#pragma once

#include "OrionFlames.h"
#include "OrionFlamesUtils.h"
#include "osl/mat4.h"
#include "ogl/util.h"

namespace OrionFlames
{
//For functions that combine GL and vector functionality.
static void DrawTexture(mat4 m, vec3 lo, vec3 hi)
{
	glBegin (GL_TRIANGLE_FAN);
		glTexCoord2f(0, 0); glVertex3fv(m * vec3(lo.x, lo.y, lo.z));
		glTexCoord2f(1, 0); glVertex3fv(m * vec3(hi.x, lo.y, lo.z));
		glTexCoord2f(1, 1); glVertex3fv(m * vec3(hi.x, hi.y, lo.z));
		glTexCoord2f(0, 1); glVertex3fv(m * vec3(lo.x, hi.y, lo.z));
	glEnd();
}

static void BadFramebuffer(GLenum status)
{
	switch(status)
	{
		case GL_FRAMEBUFFER_COMPLETE_EXT:
			oglExit("oglFramebuffer::bind", "framebuffer is actually OK (?!)");
		case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
			oglExit("oglFramebuffer::bind", "combination of formats is UNSUPPORTED by your card");
		case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
			oglExit("oglFramebuffer::bind", "ATTACHMENT_EXT");
		case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
			oglExit("oglFramebuffer::bind", "MISSING_ATTACHMENT_EXT");
		//  case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
		//  oglExit("oglFramebuffer::bind","DUPLICATE_ATTACHMENT_EXT");
		case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
			oglExit("oglFramebuffer::bind", "DIMENSIONS_EXT");
		case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
			oglExit("oglFramebuffer::bind", "FORMATS_EXT");
		case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
			oglExit("oglFramebuffer::bind", "DRAW_BUFFER_EXT");
		case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
			oglExit("oglFramebuffer::bind", "READ_BUFFER_EXT");
		default:
			oglExit("oglFramebuffer::bind", "GL_FRAMEBUFFER logic error");
	};
}
}